package gravipong;
//this line is exiting
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
//imports. i bet you never would hav guessed.
public class Main {
static int scoreOne;
static int scoreTwo;
static int scoreLim=5;
ArrayList<gravitron> gravi = new ArrayList<gravitron>();
ArrayList<ball> balls = new ArrayList<ball>();
ArrayList<paddle> pads = new ArrayList<paddle>();
animation anim;
paintable bill;
JFrameKey frame;
JMenuItem res;
String win=" ";
JLabel label;//anouncing verius things
    public static void main(String[] args) {
        new Main().setUp();//boy this is an interesting methode
    }
    public static void changeScore(boolean plus){
        if (plus)scoreOne++;//so much complicated code so early on! scary.
        else scoreTwo++;
    }
    public void setUp(){//makes balls and stuff and packes them into arraylists also gui stuff. basically lame
        frame = new JFrameKey();
        frame.addKeyListener(frame);
        frame.setDefaultCloseOperation(JFrameKey.EXIT_ON_CLOSE);
        frame.setTitle("GRAVI-PONG! :)");
        frame.setSize(615, 580);
        frame.setVisible(true);
        anim = new animation();
        frame.getContentPane().add(anim,BorderLayout.CENTER);
        //i realy should have put the randomizers in class ball but i needed to place them for testing
        ball ball1 = new ball((int) (Math.random()*8),(int)(Math.random()*8),(int)(Math.random()*600),(int)(Math.random()*500),pads);
        ball ball4 = new ball((int) (Math.random()*8),(int)(Math.random()*8),(int)(Math.random()*600),(int)(Math.random()*500),pads);
        balls.add(ball1);
        balls.add(ball4);
        gravitron gravi1 = new gravitron((int)(Math.random()*600), (int)(Math.random()*500));
        gravi.add(gravi1);
        gravitron gravi2 = new gravitron((int)(Math.random()*600), (int)(Math.random()*500));
        gravi.add(gravi2);
        paddle pad1 = new paddle(true);
        paddle pad2 = new paddle(false);
        pads.add(pad2);
        pads.add(pad1);
        label = new JLabel();
        frame.getContentPane().add(label,BorderLayout.SOUTH);// we may want to replace this with somthing more elegent but im leaving
        //it for now
        JMenuBar bar = new JMenuBar();//menu code
        frame.setJMenuBar(bar);
        JMenu options = new JMenu("Add or subtract items");
        JMenuItem incrball = new JMenuItem("Increas balls");
        incrball.addActionListener(new genericListener());
        options.add(incrball);
        JMenuItem decrball = new JMenuItem("Decrease balls");
        decrball.addActionListener(new genericListener());
        options.add(decrball);
        JMenuItem incrgrav = new JMenuItem("Increase gravity wells");
        incrgrav.addActionListener(new genericListener());
        options.add(incrgrav);
        JMenuItem decrgrav = new JMenuItem("Decrease gravity wells");
        decrgrav.addActionListener(new genericListener());
        options.add(decrgrav);
        bar.add(options);
        JMenu two = new JMenu("options");
        res = new JMenuItem("Reset game");
        res.addActionListener(new genericListener());
        two.add(res);
        JMenuItem incrScore = new JMenuItem("Increase score limit");
        incrScore.addActionListener(new genericListener());
        two.add(incrScore);
        JMenuItem decrScore = new JMenuItem("Decrease score limit");
        decrScore.addActionListener(new genericListener());
        two.add(decrScore);
        bar.add(two);
        JMenuItem mute = new JMenuItem("Mute");
        mute.addActionListener(new genericListener());
        two.add(mute);
        startLoop();
    }